package com.bt.dmdb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "ODS_USER_ROLES")
@SuppressWarnings("serial")
public class UserRole implements java.io.Serializable {

    private long id;
    private User user;
    private Role role;
    private char isPrimary;

    public UserRole() {
    }

    public UserRole(long id, User user, Role role, char isPrimary) {
        this.id = id;
        this.user = user;
        this.role = role;
        this.isPrimary = isPrimary;
    }

    @Id
    @Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
    public long getId() {
        return this.id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "USER_ID", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ROLE_ID", nullable = false)
    public Role getRole() {
        return this.role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    @Column(name = "IS_PRIMARY", nullable = false, length = 1)
    public char getIsPrimary() {
        return this.isPrimary;
    }

    public void setIsPrimary(char isPrimary) {
        this.isPrimary = isPrimary;
    }
}
